﻿using System;
using System.Collections.Generic;
using GameFramework.Battle.Core;
using Gameplay.PVE.Utils;
using RootMotion.FinalIK;
using UnityEngine;

namespace Gameplay.PVE.Survivor
{
    public class WaveShootMovement : BulletMovement
    {
        private Transform fromTransform;
        private float startTime;
        private float duration;
        public override void Start()
        {
            isFinish = false;
            fromTransform = bullet.sourceUnit.GetGunPoint(bullet.pointIndex);
            bullet.Position = fromTransform.position;
            bullet.Forward = fromTransform.forward;
            startTime = TimeManager.time;
            duration = bullet.config.destroy_param;
        }
        
        public override void Update()
        {
            bullet.Position = fromTransform.position;
            bullet.Forward = fromTransform.forward;
            bullet.HitByCollision();
            if (TimeManager.time - startTime >= duration)
            {
                isFinish = true;
            }
        }

        public override bool IsEnd()
        {
            return isFinish;
        }
    }
}
